package c.e.a.b.e.c;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/* compiled from: com.google.android.gms:play-services-measurement-base@@18.0.0 */
public final class q5 extends o5 {
    public static final Class<?> c = Collections.unmodifiableList(Collections.emptyList()).getClass();

    public q5(n5 n5Var) {
        super(null);
    }

    public final <E> void a(Object obj, Object obj2, long j) {
        obj2 = (List) l7.r(obj2, j);
        int size = obj2.size();
        List list = (List) l7.r(obj, j);
        if (list.isEmpty()) {
            if (list instanceof l5) {
                list = new m5(size);
            } else if ((list instanceof n6) && (list instanceof b5)) {
                list = ((b5) list).a(size);
            } else {
                list = new ArrayList(size);
            }
            l7.f(obj, j, list);
        } else {
            m5 arrayList;
            if (c.isAssignableFrom(list.getClass())) {
                arrayList = new ArrayList(list.size() + size);
                arrayList.addAll(list);
                l7.f(obj, j, arrayList);
            } else if (list instanceof g7) {
                arrayList = new m5(list.size() + size);
                arrayList.addAll(arrayList.size(), (g7) list);
                l7.f(obj, j, arrayList);
            } else if ((list instanceof n6) && (list instanceof b5)) {
                b5 b5Var = (b5) list;
                if (!b5Var.q()) {
                    list = b5Var.a(list.size() + size);
                    l7.f(obj, j, list);
                }
            }
            list = arrayList;
        }
        size = list.size();
        int size2 = obj2.size();
        if (size > 0 && size2 > 0) {
            list.addAll(obj2);
        }
        if (size > 0) {
            obj2 = list;
        }
        l7.f(obj, j, obj2);
    }

    public final void b(Object obj, long j) {
        Object s;
        List list = (List) l7.r(obj, j);
        if (list instanceof l5) {
            s = ((l5) list).s();
        } else if (!c.isAssignableFrom(list.getClass())) {
            if ((list instanceof n6) && (list instanceof b5)) {
                b5 b5Var = (b5) list;
                if (b5Var.q()) {
                    b5Var.w();
                }
                return;
            }
            s = Collections.unmodifiableList(list);
        } else {
            return;
        }
        l7.f(obj, j, s);
    }
}
